package util;

import dao.NewsDao;
import dao.impl.NewsDaoImpl;

/**
 * 创建NewsDao实例的工厂类
 */
public class SimpleDaoFactory {
    /**
     * 创建NewsDao实例的工厂方法
     */
   /* public static NewsDao getInstance(){
        return new NewsDaoImpl();
    }*/
    public static NewsDao getInstance(String key){
        switch (key){
            case "mysql":
                return new NewsDaoImpl();
            case "oracle":
//                return new NewsDaoOracleImpl();
            case "redis":
//                return new NewsDaoRedisImpl();
            default:
                throw new RuntimeException("无效的数据库类型："+key+",DAO获取失败");
        }
    }
}
